Skip to content

fix(tests): merge stStaticCall tests and drop fixed addresses - #4000

Draft
marioevz wants to merge 19 commits into
ethereum:forks/bogotafrom
marioevz:finalize-ported-static-static-call
Draft

marioevz wants to merge 19 commits into
ethereum:forks/bogotafrom
marioevz:finalize-ported-static-static-call

Conversation

@marioevz

Copy link
Copy Markdown
Member

Description

Warning

This PR was AI-produced. I need to manually review it before marking it ready for review.

Part of finalizing the tests/ported_static/ port: cleanup to reduce pre-alloc groups and remove pre_alloc_mutable where not needed. Files are disjoint from the other finalize-ported-static-* PRs, so each can be reviewed and merged independently.

  • Merge sibling stStaticCall files (ecrecover, precompiles, A <-> B calls, context checks, recursive bomb, call1024, hash precompiles, LOG, output, OOG_additionalGasCosts, call50000bytes) into parametrized tests.
  • Drop fixed addresses and pre_alloc_mutable.
  • Fix vacuous or wrong cases: make failed calls observable, call every RETURN bound, make loop_calls_depth_then_revert reach the ping-pong, fix a copy-paste post, and derive precompile outputs and gas.

Filled on all forks through Bogota.

Related Issues or PRs

N/A.

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <description>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

The ecrecover fillers created the signing key's EOA only so that
EQ(ORIGIN, recovered) held, which forced pre_alloc_mutable on four of
them. The recovered address is now compared against the signer as a
constant and the sender is a plain funded EOA.

The eight single-case files share one program and are merged into one
parametrized test. Every case now writes a sentinel to the output area
first, stores the raw output word (not just its low 160 bits) and
MSIZE, so a failed call or an empty output is observable instead of
reading back zeroed memory. CheckLength is subsumed by
complete_return_value, which now also stores MSIZE.

Removed:
- tests/ported_static/stStaticCall/test_static_call_ecrecover0_complete_return_value.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover0_gas2999.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover0_gas3000.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover0_no_gas.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover0_overlapping_input_output.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover2.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover_check_length.py
- tests/ported_static/stStaticCall/test_static_call_ecrecover_check_length_wrong_v.py
The three StaticcallToPrecompileFrom* fillers run the same precompile
checks from a transaction, a called contract and CREATE2 init code.
They created the signing key's EOA only so that EQ(ORIGIN, recovered)
held, which forced pre_alloc_mutable. The recovered address is now
compared against the signer as a constant, the sender is a plain
funded EOA, and the three files become one test parametrized on the
calling context, sharing one copy of the checks program. The init-code
copy differed only in forwarding 400000 gas instead of GAS to
ECRECOVER. The fork-dependent gas limits are dropped.

Removed:
- tests/ported_static/stStaticCall/test_staticcall_to_precompile_from_called_contract.py
- tests/ported_static/stStaticCall/test_staticcall_to_precompile_from_contract_initialization.py
- tests/ported_static/stStaticCall/test_staticcall_to_precompile_from_transaction.py
The ABAcalls fillers pin A and B to fixed addresses because each one
embeds the other's address, which forced pre_alloc_mutable. B now
calls back via CALLER and is deployed first, so A can embed B.

The five files become one test parametrized on the frame body
(store the call result, or bump a counter), the forwarded gas (fixed
100000/50000, or GAS - 100000), a SELFDESTRUCT to B after the call,
and storage vs memory writes (the old d0/d1). ABAcalls3 only differs
from ABAcalls2 in balances and is covered by it. ABAcalls1 and
ABAcalls2 were capped at Prague with a 1G gas block; they pass with
the default gas, so they now run on every fork from Cancun.

Posts are strengthened: the result slot is seeded with a sentinel so
the stored 0 is observable, the old d1 posts (which asserted the d0
contracts) now assert the d1 contracts, the value forwarded to A is
asserted, and the SELFDESTRUCT's balance move to B is asserted.
The result slot is a fixed slot instead of PC, since PC depends on
the push width of the embedded address.

Removed:
- tests/ported_static/stStaticCall/test_static_ab_acalls0.py
- tests/ported_static/stStaticCall/test_static_ab_acalls1.py
- tests/ported_static/stStaticCall/test_static_ab_acalls2.py
- tests/ported_static/stStaticCall/test_static_ab_acalls3.py
- tests/ported_static/stStaticCall/test_static_ab_acalls_suicide0.py
The CheckOpcodes and callTo*OpCodeCheck fillers call down a path that
goes through STATICCALL and check ORIGIN, CALLER, ADDRESS and CALLVALUE
in the innermost frame, which embeds the expected addresses. That made
the contracts reference each other (and themselves), forcing
pre_alloc_mutable on all nine files.

Bug fixed: in CheckOpcodes d1 the middle frame ignored the result of
its STATICCALL, and the nested checker compared ADDRESS against the d1
checker of the other case, so the check always failed and nobody saw
it. Replacing the nested checker with INVALID kept every case green.

The nine files become one test parametrized on the call path. The
expected context is computed by simulating the path and passed down as
calldata, so no contract embeds another's address except its callee,
and the innermost frame halts exceptionally on a mismatch. Static
frames halt when their call fails; non-static frames store their
call's success in their level's slot, so CheckOpcodes5's check of
where a CALLCODE/DELEGATECALL frame's store lands is kept. Balances are
asserted, including value moved by non-static CALLs.
Mutation checks: passing the expected CALLER as ADDRESS turns 22 of 34
Osaka cases red (the rest are CALLCODE paths, where they coincide, and
the paths that fail before the check); passing CALLVALUE + 1 turns
every path that reaches the checker red.

Dropped: the 50000-gas starved arms of CheckOpcodes, CheckOpcodes4 and
CheckOpcodes5, which asserted that the tx ran out of gas before the
nested call; that is a gas-schedule artifact, not a context check.
The callTo*OpCodeCheck paths are the CheckOpcodes2 paths.

Removed:
- tests/ported_static/stStaticCall/test_static_check_opcodes2.py
- tests/ported_static/stStaticCall/test_static_check_opcodes3.py
- tests/ported_static/stStaticCall/test_static_check_opcodes4.py
- tests/ported_static/stStaticCall/test_static_check_opcodes5.py
- tests/ported_static/stStaticCall/test_static_call_to_call_code_op_code_check.py
- tests/ported_static/stStaticCall/test_static_call_to_call_op_code_check.py
- tests/ported_static/stStaticCall/test_static_call_to_del_call_op_code_check.py
- tests/ported_static/stStaticCall/test_static_call_to_static_op_code_check.py
The callee was pinned at address 0, so the caller's expected
`{1: contract_0}` only held because the address is 0, and the fixed
address forced pre_alloc_mutable. The callee is now deployed normally,
the caller's result slot is seeded with a sentinel so the stored 0
(failed STATICCALL) is observable, and all gas is forwarded so the
failure is the static write, not out-of-gas. The tx value and balances,
which the test does not depend on, are dropped.
Mutation check: replacing STATICCALL with CALL turns the test red.
The filler's target CALLed itself (by literal address) instead of A, so
the A <-> B STATICCALL ping-pong it deploys never ran, and the literal
self-reference forced pre_alloc_mutable. The target now calls A, A
STATICCALLs B, and B STATICCALLs back via CALLER. Each frame returns
the number of frames below it that returned, plus one, and the target
stores whether that exceeds 2, so the loop must have gone A -> B -> A.
Mutation check: restoring the self-call turns the test red.
static_CallRecursiveBombPreCall and PreCall2 differ only in entering the
bomb with DELEGATECALL or STATICCALL, so they become one test
parametrized on the entry opcode. The first one self-referenced the
bomb by literal address, forcing pre_alloc_mutable. ADDRESS cannot
replace it: in the DELEGATECALL-entered frame ADDRESS is the caller,
so the bomb would call the caller once and stop. The bomb's address is
now passed as calldata instead.

The posts never depended on the recursion. Each bomb frame now returns
the number of bomb frames from itself down and the caller stores it,
asserting the depth limit (1024) is reached. The call to the fixed
empty address is now to pre.nonexistent_account().
Mutation check: using ADDRESS instead of the calldata address turns
the DELEGATECALL case red.

Removed:
- tests/ported_static/stStaticCall/test_static_call_recursive_bomb_pre_call2.py
The three Contract50 fillers differ only in the 60 KB callee: a PUSH1/
ADD chain, a run of JUMPDESTs, or a JUMP over that run. They become one
test parametrized on the callee body and on the storing (SSTORE loop,
oversized callee ending in SSTORE) vs non-storing (MSTORE) case, the
old d0/d1. The oversized code is generated instead of inlined as
480 KB of hex per file; the generated bytes and the loop contracts
are byte-identical to the ported ones.

The test stays pre_alloc_mutable and Prague-capped: the callee exceeds
the deployable code size, so it is assigned in the pre-state directly.
Every case assigns all six oversized callees at their original fixed
addresses, so the six cases share one Prague pre-alloc group (the three
files had three).

Removed:
- tests/ported_static/stStaticCall/test_static_call50000bytes_contract50_1.py
- tests/ported_static/stStaticCall/test_static_call50000bytes_contract50_2.py
- tests/ported_static/stStaticCall/test_static_call50000bytes_contract50_3.py
Bug fixed: the filler's slots 7-16 all STATICCALLed the sixth contract
(RETURN at offset 2^256-1 with size 0), so the ten contracts returning
a huge size, or a huge offset and size, were deployed but never run,
and the expected 1 in those slots held only because the sixth contract
returns no data. Each slot now calls its own bound. Those calls fail on
memory expansion, so their slots now expect 0, and they forward a
bounded 100000 gas instead of asking for 0x7ffffffffffffff (each
failure would otherwise burn 63/64 of the remaining gas and starve the
caller). The result slots are seeded with a sentinel so a stored 0 is
observable.
Mutation check: making every callee return size 0 (the old behavior)
turns the success case red.

static_RETURN_BoundsOOG is the same program followed by an out-of-gas
KECCAK256 that reverts every result; it is merged in as the
then_out_of_gas parameter. The tx value is dropped.

Removed:
- tests/ported_static/stStaticCall/test_static_return_bounds_oog.py
The 25 static_CallIdentity/Sha256/Ripemd160 fillers STATICCALL one of
the three precompiles with the same handful of inputs. They become one
test parametrized on the precompile and the input: empty (with and
without a following CALL and CALLCODE with value), a 5-byte word at
offset 5 or 0 in 37 bytes, the same with a trailing zero byte, a full
word, and a 1 MB input. The expected output is computed (hashlib) and
the call gets exactly the precompile's gas cost from the fork's gas
schedule, or one less in the one_gas_short case.

Bugs fixed:
- static_CallIdentity_2 stored the word at offset 0, like _3, unlike
  the Sha256/Ripemd160 _2 fillers (offset 5); word_at_5 now runs for
  identity too.
- the *_3_prefix0 / *_3_prefixed0 fillers MSTORE 0x00f34578907f, which
  is the same 32-byte word as 0xf34578907f, so they duplicated *_3 and
  are covered by word_at_0.
- the gas-boundary fillers were only boundaries for identity (17/18)
  and ripemd160 (719/720); sha256_4_gas99 succeeded like sha256_4
  (cost 72). Every precompile now gets cost and cost - 1.
- the *_5 fillers gave the 1 MB input too little gas, so the call just
  failed and the output word was the untouched memory; large_input now
  gets its exact cost and checks the hash of 1 MB.
The tx value, contract balances and fixed tx gas limits are dropped;
the value-bearing cases assert the precompile's balance_change.
Mutation check: giving every call one gas less turns all 21 succeeding
Osaka cases red.

Removed:
- tests/ported_static/stStaticCall/test_static_call_identitiy_1.py
- tests/ported_static/stStaticCall/test_static_call_identity_1_nonzero_value.py
- tests/ported_static/stStaticCall/test_static_call_identity_2.py
- tests/ported_static/stStaticCall/test_static_call_identity_3.py
- tests/ported_static/stStaticCall/test_static_call_identity_4.py
- tests/ported_static/stStaticCall/test_static_call_identity_4_gas17.py
- tests/ported_static/stStaticCall/test_static_call_identity_4_gas18.py
- tests/ported_static/stStaticCall/test_static_call_identity_5.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_1.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_2.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_3.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_3_postfixed0.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_3_prefixed0.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_4.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_4_gas719.py
- tests/ported_static/stStaticCall/test_static_call_ripemd160_5.py
- tests/ported_static/stStaticCall/test_static_call_sha256_1.py
- tests/ported_static/stStaticCall/test_static_call_sha256_1_nonzero_value.py
- tests/ported_static/stStaticCall/test_static_call_sha256_2.py
- tests/ported_static/stStaticCall/test_static_call_sha256_3.py
- tests/ported_static/stStaticCall/test_static_call_sha256_3_postfix0.py
- tests/ported_static/stStaticCall/test_static_call_sha256_3_prefix0.py
- tests/ported_static/stStaticCall/test_static_call_sha256_4.py
- tests/ported_static/stStaticCall/test_static_call_sha256_4_gas99.py
- tests/ported_static/stStaticCall/test_static_call_sha256_5.py
static_Call1024PreCalls3 is identical to static_Call1024PreCalls, and
static_Call1024BalanceTooLow2 to static_Call1024BalanceTooLow except
that its d1 post asserted the d0 contract; the duplicates are removed
and their fillers added to the kept files' ported_from.
static_Call1024PreCalls2's d1 post also asserted the d0 contract; it
now asserts the d1 (MSTORE) contract. All three stay Prague-capped.

Removed:
- tests/ported_static/stStaticCall/test_static_call1024_balance_too_low2.py
- tests/ported_static/stStaticCall/test_static_call1024_pre_calls3.py
The 13 static_log* fillers STATICCALL a contract that runs LOG0-LOG4
with various memory ranges and topics. A LOG in a static frame fails
the call, so they all stored 0 in a fresh slot, which is
indistinguishable from not storing. They become one test parametrized
on the topic count, memory range and last topic (ids follow the old
file names; log_Caller's five d cases are log0_non_empty_mem and
log1_caller..log4_caller). The result slot is seeded with a sentinel
and the caller stores a completion flag after the call. All gas is
forwarded instead of 1000, so the failure is the static rule, not an
out-of-gas, and the tx value and fixed gas limit are dropped.
Mutation check: replacing STATICCALL with CALL turns the 12 cases with
a valid memory range red.

Removed:
- tests/ported_static/stStaticCall/test_static_log0_empty_mem.py
- tests/ported_static/stStaticCall/test_static_log0_log_mem_start_too_high.py
- tests/ported_static/stStaticCall/test_static_log0_log_memsize_too_high.py
- tests/ported_static/stStaticCall/test_static_log0_log_memsize_zero.py
- tests/ported_static/stStaticCall/test_static_log0_non_empty_mem.py
- tests/ported_static/stStaticCall/test_static_log0_non_empty_mem_log_mem_size1.py
- tests/ported_static/stStaticCall/test_static_log0_non_empty_mem_log_mem_size1_log_mem_start31.py
- tests/ported_static/stStaticCall/test_static_log1_empty_mem.py
- tests/ported_static/stStaticCall/test_static_log1_log_mem_start_too_high.py
- tests/ported_static/stStaticCall/test_static_log1_log_memsize_too_high.py
- tests/ported_static/stStaticCall/test_static_log1_log_memsize_zero.py
- tests/ported_static/stStaticCall/test_static_log1_max_topic.py
- tests/ported_static/stStaticCall/test_static_log_caller.py
The six static_callOutput* fillers STATICCALL a callee that either
writes storage or underflows the stack, with the input and output
areas over a memory word the caller then stores. Every callee failed,
so all six posts asserted the untouched word. They become one test
parametrized on the (args size, return size) of the old files and the
callee kind; a callee that returns a word is added, so the full and
partial copies of the output over the memory are checked too. The
call's success flag is now stored (over a sentinel). Gas, value and
balances the test does not depend on are dropped.
Mutation check: replacing STATICCALL with CALL turns the storage-
writing callee's cases red.

Removed:
- tests/ported_static/stStaticCall/test_static_call_output1.py
- tests/ported_static/stStaticCall/test_static_call_output2.py
- tests/ported_static/stStaticCall/test_static_call_output3.py
- tests/ported_static/stStaticCall/test_static_call_output3_fail.py
- tests/ported_static/stStaticCall/test_static_call_output3partial.py
- tests/ported_static/stStaticCall/test_static_call_output3partial_fail.py
The two fillers differ only in the STATICCALL target: a fixed empty
address or a funded EOA. They become one test parametrized on that,
with the empty target from pre.nonexistent_account(). The 30000 gas
limit is the subject (the caller's stores cannot be paid) and is kept;
both cases now assert the reverted caller storage, the sender's nonce
and the target's state.
Mutation check: a 300000 gas limit turns both cases red.

Removed:
- tests/ported_static/stStaticCall/test_static_call_oog_additional_gas_costs1.py
- tests/ported_static/stStaticCall/test_static_call_oog_additional_gas_costs2_paris.py
Annotate the seeded storage dicts, the LOG topic list, the A <-> B
callee and the OOG callee so the merged tests pass strict mypy. No
change to the generated fixtures.
@marioevz marioevz added this to the Finalize Ported-Static milestone Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.13%. Comparing base (4c8ae33) to head (fbd6806).
⚠️ Report is 12 commits behind head on forks/bogota.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/bogota    #4000      +/-   ##
================================================
+ Coverage         95.10%   95.13%   +0.02%     
================================================
  Files               673      673              
  Lines             40904    40904              
  Branches           3778     3778              
================================================
+ Hits              38903    38913      +10     
+ Misses             1393     1388       -5     
+ Partials            608      603       -5     
Flag Coverage Δ
unittests 95.12% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danceratopz danceratopz added the A-tests Area: Consensus tests. label Nov 17, 2026

@spencer-tb spencer-tb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! AI Swarm Review, 3x rotation of 10 fresh agents, findings re-checked by fills, traces and spec mutants, small things inline :)

Checked: every ported_from entry against the fillers, the derived precompile outputs, the slow files in a full-range fill, a leading-zero address fill, and spec mutants of try/catch rules against base.

@danceratopz danceratopz left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup: 85 files down to 16, and the fixes (sentinels, the return-bounds callees, the CheckOpcodes d1 checker) are real improvements. Nothing blocking.

No filler dropped: the 2,098 ported_from references are all still there. The full stStaticCall fill passes (2,073 cases through Bogota). On Cancun the touched files went from 150 cases to 124, and every base case maps to a new case or a drop stated in a commit message, except CheckOpcodes3, which Spencer already raised inline (I replied there).

My agent ran the same checks as described in the #3997 review.

Main point: the identity output check can't fail, see inline on test_static_call_hash_precompiles.py line 177.

Area: legacy comments
Priority: Normal

In the touched files, # Source: blocks went from 233 to 11 and legacy comment lines from 298 to 41; raw hex code went from 6 sites to 0. Four of the 16 head files still carry blocks. The one in test_staticcall_to_precompile.py is misleading: the file is new, and the block is cut off, half edited and doesn't show the init-code copy's 400000 gas (inline comment on the block). The three call1024 files quote fixed <contract:0x...> and <eoa:0x...> addresses where the code now uses Op.ADDRESS or the addr account; the logic matches, so those are only redundant.

Files with legacy blocks at the head
  • test_staticcall_to_precompile.py: 1 block (truncated with # ... (70 more lines), <signer> placeholder). Misleading.
  • test_static_call1024_pre_calls.py: 3 blocks. Redundant.
  • test_static_call1024_pre_calls2.py: 4 blocks. Redundant.
  • test_static_call1024_balance_too_low.py: 3 blocks. Redundant.

Area: clean-up in the same directory
Priority: Minor

Left in stStaticCall, not handled by #4001 or #4005. None needs to block.

  • test_static_call1024_pre_calls.py and test_static_call1024_pre_calls2.py differ only in STATICCALL vs DELEGATECALL in the recursive callees, the addr account and the expected post. They could be one test with an opcode parameter.
  • The three call1024 files this PR edits still have placeholder docstrings ("""Test_static_call1024_pre_calls.""" and similar).
Follow-up candidates
  • test_static_call_recursive_bomb_log.py and ..._log2.py differ only in the MSTORE value (a constant vs GAS) and the sender nonce in the post.
  • test_static_call50000_identity.py and ..._rip160.py have the same shape as the contract50 merge (precompile address, gas, post).

Area: PR description
Priority: Minor

The cases dropped on purpose are listed only in the commit messages, which the squash merge won't keep: ABAcalls3 (covered by ABAcalls2), the CheckOpcodes 50000-gas arms, static_Call1024PreCalls3 and static_Call1024BalanceTooLow2 (duplicates), the *_3_prefix0 / *_3_prefixed0 duplicates, the duplicate return_bounds_oog d1 case, and log_Caller d0 (same as log0_non_empty_mem). Could you add them to the PR body? Also ABAcalls1 and ABAcalls2 now run on Osaka and later (they were capped at Prague).

Return into a sentinel-seeded area separate from the input, so an
identity call that writes nothing no longer matches. Add a large-input
one-gas-short case for the *_5 fillers.
Add the paths with a non-static hop between two STATICCALLs.
Remove the truncated LLL block in staticcall_to_precompile and the
redundant ones in the call1024 files, replace their placeholder
docstrings, and note that the static_log too-high ranges fail on the
memory expansion charge.
@danceratopz danceratopz mentioned this pull request Nov 20, 2026
13 of 27 tasks

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @marioevz for the fixes, they all check out. I asked my agent to re-check the new head and it found no case dropped by mistake (same method as the #3997 review).

Comment inline.

Could you list the cases dropped on purpose in the PR body? The squash merge won't keep the commit messages.

Suggested PR body text
Dropped on purpose: `ABAcalls3` (covered by `ABAcalls2`), the CheckOpcodes 50000-gas arms, `static_Call1024PreCalls3`, `static_Call1024BalanceTooLow2`, the `*_3_prefix0` / `*_3_prefixed0` cases and the `return_bounds_oog` d1 case (duplicates), and `log_Caller` d0 (same as `log0_non_empty_mem`).


Ported from:
state_tests/stStaticCall/static_Call1024PreCallsFiller.json
state_tests/stStaticCall/static_Call1024PreCalls3Filler.json

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_static_call1024_pre_calls2.py differs from this file only in the recursive opcode (DELEGATECALL instead of STATICCALL), the twice-called account (a contract instead of an EOA) and the storing variant's post. Could you fold it in here with a recursive_call parameter, like the other merges in this PR? I asked my agent to try it: the merged test fills the same 8 fixtures as the two files today (byte-identical apart from _info) on Cancun and Prague.

Merged test (verified diff)

Applied at fbd6806: ruff format, ruff check and mypy clean; fill --from Cancun --until Prague -m state_test gives 8 passed, and all 8 fixtures match today's pre_calls / pre_calls2 fixtures apart from _info.

diff --git a/tests/ported_static/stStaticCall/test_static_call1024_pre_calls.py b/tests/ported_static/stStaticCall/test_static_call1024_pre_calls.py
index 1c9a6a507d..96d1d2fb82 100644
--- a/tests/ported_static/stStaticCall/test_static_call1024_pre_calls.py
+++ b/tests/ported_static/stStaticCall/test_static_call1024_pre_calls.py
@@ -1,14 +1,16 @@
 """
-STATICCALL an account twice, then STATICCALL self recursively.
+STATICCALL an account twice, then STATICCALL or DELEGATECALL self recursively.
 
 Ported from:
 state_tests/stStaticCall/static_Call1024PreCallsFiller.json
+state_tests/stStaticCall/static_Call1024PreCalls2Filler.json
 state_tests/stStaticCall/static_Call1024PreCalls3Filler.json
 """
 
 import pytest
 from execution_testing import (
     Account,
+    Address,
     Alloc,
     Environment,
     Hash,
@@ -16,7 +18,7 @@ from execution_testing import (
     Transaction,
 )
 from execution_testing.forks import Fork
-from execution_testing.vm import Op
+from execution_testing.vm import Op, Opcode
 
 from tests.ported_static.constants import HIGH_GAS_LIMIT
 from tests.ported_static.post_state_resolution import (
@@ -30,12 +32,20 @@ REFERENCE_SPEC_VERSION = "N/A"
 @pytest.mark.ported_from(
     [
         "state_tests/stStaticCall/static_Call1024PreCallsFiller.json",
+        "state_tests/stStaticCall/static_Call1024PreCalls2Filler.json",
         "state_tests/stStaticCall/static_Call1024PreCalls3Filler.json",
     ],
 )
 @pytest.mark.valid_from("Cancun")
 @pytest.mark.valid_until("Prague")
 @pytest.mark.slow
+@pytest.mark.parametrize(
+    "recursive_call",
+    [
+        pytest.param(Op.STATICCALL, id="staticcall"),
+        pytest.param(Op.DELEGATECALL, id="delegatecall"),
+    ],
+)
 @pytest.mark.parametrize(
     "d, g, v",
     [
@@ -57,22 +67,26 @@ def test_static_call1024_pre_calls(
     state_test: StateTestFiller,
     pre: Alloc,
     fork: Fork,
+    recursive_call: Opcode,
     d: int,
     g: int,
     v: int,
 ) -> None:
     """
     Verify a contract that STATICCALLs an account twice and then
-    STATICCALLs itself recursively.
+    STATICCALLs or DELEGATECALLs itself recursively.
 
-    The storing variant fails at its first store in a static frame, the
-    memory-only variant recurses until it runs out of depth or gas.
+    With STATICCALL the account is an EOA, and the storing variant fails
+    at its first store in a static frame. With DELEGATECALL the account
+    is a contract, and the storing variant recurses until it runs out of
+    depth or gas. The memory-only variant recurses either way.
     """
     env = Environment(gas_limit=HIGH_GAS_LIMIT)
 
     sender = pre.fund_eoa(amount=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
 
-    addr = pre.fund_eoa(amount=7000)
+    if recursive_call == Op.STATICCALL:
+        addr: Address = pre.fund_eoa(amount=7000)
     target = pre.deploy_contract(
         code=Op.SSTORE(
             key=0x0,
@@ -89,6 +103,11 @@ def test_static_call1024_pre_calls(
         + Op.SSTORE(key=0x1, value=0x1)
         + Op.STOP,
     )
+    if recursive_call == Op.DELEGATECALL:
+        addr = pre.deploy_contract(
+            code=Op.MSTORE(offset=0x0, value=0x1) + Op.STOP,
+            balance=7000,
+        )
     addr_2 = pre.deploy_contract(
         code=Op.SSTORE(
             key=0x2,
@@ -115,7 +134,7 @@ def test_static_call1024_pre_calls(
         + Op.SSTORE(key=0x0, value=Op.ADD(Op.SLOAD(key=0x0), 0x1))
         + Op.SSTORE(
             key=0x1,
-            value=Op.STATICCALL(
+            value=recursive_call(
                 gas=0xFFFFFFFFFFF,
                 address=Op.ADDRESS,
                 args_offset=0x0,
@@ -140,7 +159,7 @@ def test_static_call1024_pre_calls(
         )
         * 2
         + Op.MSTORE(offset=0x0, value=Op.ADD(Op.MLOAD(offset=0x0), 0x1))
-        + Op.STATICCALL(
+        + recursive_call(
             gas=0xFFFFFFFFFFF,
             address=Op.ADDRESS,
             args_offset=0x0,
@@ -152,12 +171,17 @@ def test_static_call1024_pre_calls(
         balance=2024,
     )
 
+    addr_2_storage = (
+        {0: 1, 1: 0, 2: 1, 3: 1}
+        if recursive_call == Op.STATICCALL
+        else {0: 1024, 1: 1, 2: 0, 3: 0}
+    )
     expect_entries_: list[dict] = [
         {
             "indexes": {"data": 0, "gas": -1, "value": -1},
             "network": [">=Cancun<Osaka"],
             "result": {
-                addr_2: Account(storage={0: 1, 1: 0, 2: 1, 3: 1}),
+                addr_2: Account(storage=addr_2_storage),
                 target: Account(storage={0: 1, 1: 1}),
             },
         },
diff --git a/tests/ported_static/stStaticCall/test_static_call1024_pre_calls2.py b/tests/ported_static/stStaticCall/test_static_call1024_pre_calls2.py
deleted file mode 100644
index 88fd43d702..0000000000
--- a/tests/ported_static/stStaticCall/test_static_call1024_pre_calls2.py
+++ /dev/null
@@ -1,188 +0,0 @@
-"""
-STATICCALL a contract twice, then DELEGATECALL self recursively.
-
-Ported from:
-state_tests/stStaticCall/static_Call1024PreCalls2Filler.json
-"""
-
-import pytest
-from execution_testing import (
-    Account,
-    Alloc,
-    Environment,
-    Hash,
-    StateTestFiller,
-    Transaction,
-)
-from execution_testing.forks import Fork
-from execution_testing.vm import Op
-
-from tests.ported_static.constants import HIGH_GAS_LIMIT
-from tests.ported_static.post_state_resolution import (
-    resolve_expect_post,
-)
-
-REFERENCE_SPEC_GIT_PATH = "N/A"
-REFERENCE_SPEC_VERSION = "N/A"
-
-
-@pytest.mark.ported_from(
-    ["state_tests/stStaticCall/static_Call1024PreCalls2Filler.json"],
-)
-@pytest.mark.valid_from("Cancun")
-@pytest.mark.valid_until("Prague")
-@pytest.mark.slow
-@pytest.mark.parametrize(
-    "d, g, v",
-    [
-        pytest.param(
-            0,
-            0,
-            0,
-            id="d0",
-        ),
-        pytest.param(
-            1,
-            0,
-            0,
-            id="d1",
-        ),
-    ],
-)
-def test_static_call1024_pre_calls2(
-    state_test: StateTestFiller,
-    pre: Alloc,
-    fork: Fork,
-    d: int,
-    g: int,
-    v: int,
-) -> None:
-    """
-    Verify a contract that STATICCALLs another contract twice and then
-    DELEGATECALLs itself recursively until it runs out of depth or gas.
-    """
-    env = Environment(gas_limit=HIGH_GAS_LIMIT)
-
-    sender = pre.fund_eoa(amount=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
-
-    target = pre.deploy_contract(
-        code=Op.SSTORE(
-            key=0x0,
-            value=Op.CALL(
-                gas=Op.GAS,
-                address=Op.CALLDATALOAD(offset=0x0),
-                value=Op.CALLVALUE,
-                args_offset=0x0,
-                args_size=0x0,
-                ret_offset=0x0,
-                ret_size=0x0,
-            ),
-        )
-        + Op.SSTORE(key=0x1, value=0x1)
-        + Op.STOP,
-    )
-    addr = pre.deploy_contract(
-        code=Op.MSTORE(offset=0x0, value=0x1) + Op.STOP,
-        balance=7000,
-    )
-    addr_2 = pre.deploy_contract(
-        code=Op.SSTORE(
-            key=0x2,
-            value=Op.STATICCALL(
-                gas=0xFFFF,
-                address=addr,
-                args_offset=0x0,
-                args_size=0x0,
-                ret_offset=0x0,
-                ret_size=0x0,
-            ),
-        )
-        + Op.SSTORE(
-            key=0x3,
-            value=Op.STATICCALL(
-                gas=0xFFFF,
-                address=addr,
-                args_offset=0x0,
-                args_size=0x0,
-                ret_offset=0x0,
-                ret_size=0x0,
-            ),
-        )
-        + Op.SSTORE(key=0x0, value=Op.ADD(Op.SLOAD(key=0x0), 0x1))
-        + Op.SSTORE(
-            key=0x1,
-            value=Op.DELEGATECALL(
-                gas=0xFFFFFFFFFFF,
-                address=Op.ADDRESS,
-                args_offset=0x0,
-                args_size=0x0,
-                ret_offset=0x0,
-                ret_size=0x0,
-            ),
-        )
-        + Op.STOP,
-        balance=2024,
-    )
-    addr_3 = pre.deploy_contract(
-        code=Op.POP(
-            Op.STATICCALL(
-                gas=0xFFFF,
-                address=addr,
-                args_offset=0x0,
-                args_size=0x0,
-                ret_offset=0x0,
-                ret_size=0x0,
-            )
-        )
-        * 2
-        + Op.MSTORE(offset=0x0, value=Op.ADD(Op.MLOAD(offset=0x0), 0x1))
-        + Op.DELEGATECALL(
-            gas=0xFFFFFFFFFFF,
-            address=Op.ADDRESS,
-            args_offset=0x0,
-            args_size=0x0,
-            ret_offset=0x0,
-            ret_size=0x0,
-        )
-        + Op.STOP,
-        balance=2024,
-    )
-
-    expect_entries_: list[dict] = [
-        {
-            "indexes": {"data": 0, "gas": -1, "value": -1},
-            "network": [">=Cancun<Osaka"],
-            "result": {
-                addr_2: Account(storage={0: 1024, 1: 1, 2: 0, 3: 0}),
-                target: Account(storage={0: 1, 1: 1}),
-            },
-        },
-        {
-            "indexes": {"data": 1, "gas": -1, "value": -1},
-            "network": [">=Cancun<Osaka"],
-            "result": {
-                addr_3: Account(storage={0: 0, 1: 0, 2: 0, 3: 0}),
-                target: Account(storage={0: 1, 1: 1}),
-            },
-        },
-    ]
-
-    post, _exc = resolve_expect_post(expect_entries_, d, g, v, fork)
-
-    tx_data = [
-        Hash(addr_2, left_padding=True),
-        Hash(addr_3, left_padding=True),
-    ]
-    tx_gas = [9214364837600034817]
-    tx_value = [10]
-
-    tx = Transaction(
-        sender=sender,
-        to=target,
-        data=tx_data[d],
-        gas_limit=tx_gas[g],
-        value=tx_value[v],
-        error=_exc,
-    )
-
-    state_test(env=env, pre=pre, post=post, tx=tx)

@chfast

chfast commented Dec 3, 2026

Copy link
Copy Markdown
Member

Two suggestions for the "Finalize Ported-Static" milestone.

1. Lower HIGH_GAS_LIMIT. It is 2**63 - 1 (tests/ported_static/constants.py) and is used only as the block gas limit, Environment(gas_limit=HIGH_GAS_LIMIT). Before Osaka this also makes it the implicit tx gas limit. The milestone PRs drop it from 48 of the 78 files that use it, leaving 30. I suggest a realistic value instead: 50M, 100M or 120M. 120M is DEFAULT_BLOCK_GAS_LIMIT, so at that value the override can simply be removed.

I ran the 30 remaining tests in geth on the v21.0.3 fixtures with both the block and the tx gas limit set to the new value. For each I compared the opcode trace and the post-state hash with the original:

  • Identical at 120M (7 tests): call_recursive_bomb0, call_recursive_bomb_log, call_recursive_bomb_log2, static_call_recursive_bomb0, static_call50000_identity2, mload_bounds3, mstore_bounds2a. At 50M and 100M only the last two are identical.
  • Same path, different post state: random_statetest308 runs the same 15 opcodes, but its post state changes, so the expectation needs re-pinning.
  • One case changes: in base_fee_diff_places and gas_price_diff_places, 1 of 35 cases changes.
  • The rest need far more gas: these are call-depth tests (call1024_*, *recursive_bomb_pre_call, *_oog_at_max_call_depth, static_loop_calls_depth_then_revert*, static_call1024_*) or tests that use more than 120M gas. After EIP-150, reaching call depth 1024 needs on the order of 1e10 gas. For example, at 120M static_call_recursive_bomb_pre_call stops at depth 395 instead of 1025. These tests should keep an explicit, named budget of their own rather than a shared 2**63 - 1.

2. Rename suicide to selfdestruct in test names. The opcode has been SELFDESTRUCT since EIP-6, but the old name is still widespread:

The ported_from filler paths should stay unchanged, so the original source can still be found.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tests Area: Consensus tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants